package sort;

/**
 * Created by Administrator on 2017/3/14.
 */
public class InesrtionSort {
    public void sort(int[] array) {
        for (int i = 1; i < array.length; i++) {
            inesrt(array,i);
        }
    }

    private void inesrt(int[] array,int k){
        int key = array[k];
        int i;
        for (i = k - 1; i >= 0 && array[i] > key; i--) {
            array[i + 1] = array[i];
        }
        array[i + 1] = key;
    }
}
